feat(cli): abbreviate large pasted text and optimize paste performance#4916
feat(cli): abbreviate large pasted text and optimize paste performance#4916marius-kilocode merged 5 commits intomainfrom
Conversation
🦋 Changeset detectedLatest commit: 23b2132 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Code Review SummaryStatus: No Issues Found | Recommendation: Merge OverviewThis PR adds a feature to abbreviate large pasted text in the CLI input field. When users paste text with 10+ lines, it displays as Key Changes:
Code Quality:
Files Reviewed (6 files)
|
| @@ -0,0 +1,28 @@ | |||
| // Regex to match pasted text references: [Pasted text #N +X lines] | |||
| export const PASTED_TEXT_REFERENCE_REGEX = /\[Pasted text #(\d+) \+(\d+) lines\]/g | |||
There was a problem hiding this comment.
I think this is ok for now, but a much better approach for the future, in my opinion, would be to refactor the input field to be an array of objects, for example:
type PasteItem = {
type: "paste";
text: string;
}
type ImageItem = {
type: "image";
pathToFile: string;
}
type StringItem = {
type: "string";
value: string;
}
type InputFieldValue = PasteItem | ImageItem | StringItem;
type InputFieldState = InputFieldValue[];
// then, in the component
const [inputFieldState, setInputFieldState] = useState<InputFieldState>([]);
// refactor the renderer to correctly render input field state
function render(state: InputFieldState): string
// refactor state updaters to correctly handle the new shape
function handleX(cursorPosition: number, event: unknown): InputFieldStateThere was a problem hiding this comment.
Looking back at this, I agree. This is the better approach. I will get a follow up done.
VSCode terminal sends empty bracketed paste sequences for Cmd+V, unlike regular terminals that send key events directly. This was broken in Kilo-Org#4916 when the condition changed to skip empty pastes. Now we check the clipboard for images when receiving an empty bracketed paste, restoring the behavior from Kilo-Org#4832.
VSCode terminal sends empty bracketed paste sequences for Cmd+V, unlike regular terminals that send key events directly. This was broken in #4916 when the condition changed to skip empty pastes. Now we check the clipboard for images when receiving an empty bracketed paste, restoring the behavior from #4832. Co-authored-by: Jérémy Beutin <jeremybeutin@MacBook-Pro-de-Jeremy.local>
Summary
[Pasted text #N +X lines]to prevent input field overflow when pasting logs or large code blocksChanges
processPastedText.tsutilities for handling pasted text references (extract, remove, expand)keyboard.tswithhandlePastefunctionuseMessageHandler.tsbefore sending messagesKeyboardProvider.tsxto skip osascript clipboard check for bracketed pastesHow it works
[Pasted text #1 +X lines]